//import java.util.Scanner;
//
//public class Main {
//    public static void main(String[] args) {
//        Scanner sc=new Scanner(System.in);
//        int n=sc.nextInt();
//        Vehicle[] vehicles=new Vehicle[n];
//        for(int i=0;i<n;i++){
//            int type=sc.nextInt();
//            if(type==1){
//                int load=sc.nextInt();
//                vehicles[i]=new Truck(load);
//            }else if(type==2){
//                int level=sc.nextInt();
//                vehicles[i]=new Car(level);
//            }
//        }
//        System.out.println(CarRentCompany.rentVehicles(vehicles));
//    }
//}
//abstract class Vehicle{
//    abstract public int rent();
//}
//class Truck extends Vehicle{
//    int load;
//
//    public Truck(int load) {
//        this.load = load;
//    }
//
//    public int rent(){
//        return load*1000;
//    }
//}
//class Car extends Vehicle{
//    int level;
//    public Car(int level){
//        this.level=level;
//    }
//    public int rent(){
//        return level*200;
//    }
//}
//class CarRentCompany{
//    public static int rentVehicles(Vehicle[] vehicles){
//        int sum=0;
//        for(Vehicle v:vehicles){
//            sum+=v.rent();
//        }
//        return sum;
//    }
//}

//import java.util.Scanner;
//
//interface Biology{
//    abstract void breathe();
//}
//interface Animal{
//    abstract void eat();
//    abstract void sleep();
//}
//class Person implements Biology,Animal{
//    @Override
//    public void breathe() {
//        System.out.println("我喜欢呼吸新鲜空气");
//    }
//
//    @Override
//    public void eat() {
//        System.out.println("我会按时吃饭");
//    }
//
//    @Override
//    public void sleep() {
//        System.out.println("早睡早起身体好");
//    }
//    public void think() {
//        System.out.println("我喜欢思考");
//    }
//}
//class Pupil extends Person{
//    private String school;
//
//    public void setSchool(String school) {
//        this.school = school;
//    }
//
//    public String getSchool() {
//        return school;
//    }
//
//}
//public class Main{
//    public static void main(String[] args) {
//        Scanner sc=new Scanner(System.in);
//        Pupil zhangsan=new Pupil();
//        String school=sc.nextLine();
//        zhangsan.setSchool(school);
//        System.out.println("我的学校是"+zhangsan.getSchool());
//        zhangsan.breathe();
//        zhangsan.eat();
//        zhangsan.sleep();
//        zhangsan.think();
//    }
//}

import java.util.Scanner;

abstract class Express{
    int weight;
    abstract int getWeight();
    abstract int getTotal();
}
class SLExpress extends Express{

    public SLExpress(int weight) {
        this.weight = weight;
    }

    @Override
    int getTotal() {
        if(weight<=1){
            return 12;
        }else{
            return 12+(weight-1)*2;
        }
    }

    @Override
    int getWeight() {
        return weight;
    }
}
class DDExpress extends Express{

    public DDExpress(int weight) {
        this.weight = weight;
    }

    @Override
    int getTotal() {
        if(weight<=1){
            return 5;
        }else{
            return 5+(weight-1)*1;
        }
    }

    @Override
    int getWeight() {
        return weight;
    }
}
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int sum=0;
        for(int i=0;i<n;i++){
            Express express;
            String line = sc.nextLine();   // 读取一整行，如 "SL 2"
            String[] parts = line.split(" ");
            String name = parts[0];
            int weight = Integer.parseInt(parts[1]);
            if(name.equals("SL")){
                express=new SLExpress(weight);
            }else{
                express=new DDExpress(weight);
            }
            sum+=express.getTotal();
        }
        System.out.println(sum);
    }
}